package com.entor.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.entor.dao.MeetingDaoI;
import com.entor.model.MeetingEntity;
import com.entor.model.MeetingMemberEntity;
import com.entor.model.Msg;
@Service
public class MeetingService implements BaseServiceI<MeetingEntity>{

	@Autowired
	private MeetingDaoI meetingDI;
	
	public List<MeetingEntity> find(MeetingEntity t) {
		return meetingDI.find(t);
	}

	public MeetingEntity get(MeetingEntity t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg insert(MeetingEntity t) {
		int i = meetingDI.insert(t);
		Msg msg = new Msg("插入失败",false,null);
		if(i>0){
			msg = new Msg("插入成功",true,null);
		}
		return msg;
	}

	public Msg batchInsert(String objs) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg edit(MeetingEntity t) {
		Msg msg = new Msg("修改失败",false,null); 
		int i = meetingDI.edit(t);
		if(i>0){
			msg = new Msg("修改成功",true,null);
		}
		return msg;
	}

	public Msg remove(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg batchRemove(String ids) {
		// TODO Auto-generated method stub
		return null;
	}

	
	public Msg joinMeeting(MeetingEntity entity,int memberId){
		Msg msg = new Msg("加入失败",false,null);
		int i = meetingDI.joinMeeting(entity.getId(), memberId);
		if(i>0){
			msg = new Msg("加入成功",true,null);
		}
		return msg;
	}
	
	public List<MeetingMemberEntity> findJoin(MeetingEntity entity,int memberId){
		List<MeetingMemberEntity> list = new ArrayList<MeetingMemberEntity>();
		if(entity!=null){
			System.out.println("null");
			list = meetingDI.findJoin(entity.getId(), memberId);
		}else{
			System.out.println("not");
			list = meetingDI.findJoin(null, memberId);
		}
		return list;
	}
}
